#!/usr/bin/perl
use strict;
use warnings; 
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;

#MoTDStats is released under the MIT License, a copy is provided in the INFO.html file.
#This is version 0.0.0f (Lists all cygdrives/Windows drives from C: to Z:, tested and confirmed working on Windows after installing the CoreUtils,SharUtils and grep packages from http://gnuwin32.sourceforge.net, and ActivePerl).

#Change these settings to suit, comments are provided next to each option you can change.
my $ColourPrinting = 1; # 1 turns username/date banner colour on, 0 turns it off 
my $DFPlatform = "Autodetect"; #For most people this should be Autodetect.
my $unameNote = "You're running on";

#DO NOT MODIFY THESE!
my $uname = `uname -sm`;
my $username = $ENV{'LOGNAME'} || $ENV{'USER'} || $ENV{'USERNAME'};
my $date = `date`;
my $Nodes = "sd|hd|ad|da|disk|wd|md|vn|lv|[c-z]:|[C-Z]:|dsk"; #This should be suitable for the vast majority of platforms, do not remove it.

#NOTHING BELOW THIS LINE SHOULD BE MODIFIED, UNLESS YOU HAVE A GOOD REASON FOR IT.


sub UNAME {
	print "$unameNote $uname\n";
}

sub UserDate {
	if ($ColourPrinting == 1) {
		print WHITE ON_BLUE "Currently logged in as $username. Today is $date";
	}

	if ($ColourPrinting == 0) {
		print "Currently logged in as $username. Today is $date";
	} 
	print "\n";
}

sub DiskFree {
	my $GNUdf_hOut="Filesystem            Size  Used Avail Use% Mounted on\n";
	my $QNXPOSIXdf_Out="Filesystem            512-blocks      Used Available Capacity Mounted on\n";
	my $AIX1Kdf="Filesystem    1024 blocks    Free    %Used   Iused  %Iused  Mounted on\n";


	if ($DFPlatform eq "Autodetect") {
		my $DiskFreeInfo_sd=`df -h | grep -E "$Nodes"`;
		print $GNUdf_hOut;
		print "$DiskFreeInfo_sd\n";
	}

	if ($DFPlatform eq "QNX") {
		print $QNXPOSIXdf_Out;
		print `df -P | grep hd`;
		print "\n";
	}

	if ($DFPlatform eq "AIX") {
		print $AIX1Kdf;
		print `df -k | grep -E "$Nodes"`;
		print "\n";
	}
}

sub Fortune {
	print `fortune`;
	print "\n";
}

#You may reorder these, or remove items you don't need, do not modify the source code above, though.

UserDate();
UNAME();
DiskFree();
